<h1>Сообщения</h1>
<div class="message-tabs">
    {if $mode == 'inbox'}
    <span class="active">Входящие</span>
    <a href="/message/outbox">Исходящие</a>
    {/if}
    {if $mode == 'outbox'}
    <a href="/message/inbox">Входящие</a>
    <span class="active">Исходящие</span>
    {/if}
</div>

    {if count($mails) == 0}
        Сообщений нет.
    {/if}
    {foreach from=$mails item=mail}
    {if ($mode == "outbox")}
        {assign var=mailUser value=UserFacade::getUserById($mail->to_user)}
        {assign var=mailUserId value=$mail->to_user}
    {else}    
        {assign var=mailUser value=UserFacade::getUserById($mail->from_user)}
        {assign var=mailUserId value=$mail->from_user}
    {/if}
    <div class="message-item">
        <div class="user-photo">
            <a href="/user/{$mailUser->user_id}">
                {assign var="avatarSrc" value=UploadImageFacade::resolveImagePath($mailUser->avatar_id, "84x123")}
                <img src="{$avatarSrc}" alt="" width="84" height="123" />
            </a>
        </div>
        <div class="message-info">
            <p class="author"><a href="{$controller->getUserPageUrl($mailUser->user_id)}">
                {UserFacade::getFullNameUser($mailUser->user_id)}</a>
            </p>
            <span class="date">{$mail->send_date|date_format:"%Y:%m:%d %H:%M"}</span>
            <p class="title">Тема: {$mail->title}</p>
            <p class="text">{$mail->message}</p>
        </div>
        <div class="message-controls">
            {if ($mode == "inbox")}
            <a href="/message/send/{$mail->from_user}">Ответить</a>
            {/if}
            <a href="/message/delete/{$mail->message_id}">Удалить</a>
        </div>
    </div>
    {/foreach}